<?php

include_once 'controller/default.php';
include_once 'model/board/process.php';
if (isset($_POST)) {
    $board = new boards();
    if (isset($_POST["accept"])) {
        $insert = $board->Insert($_POST);
        if ($insert) {
            echo '<script>alert("Thêm Board thành công.")</script>';
            include 'view/board/board_manager.php';
        } else {
            echo '<script>alert("Thêm Board thất bại.")</script>';
            include 'view/board/board_create.php';
        }
    } else if (isset($_POST["update"])) {
        $update = $board->Update($_POST);
        if ($update) {
            echo '<script>alert("Sửa Board thành công.")</script>';
            include 'view/board/board_manager.php';
        } else {
            echo '<script>alert("Sửa Board thất bại.")</script>';
            include 'view/board/board_update.php';
        }
    } else if (isset($_POST["updateorder"])) {
        $update = $board->UpdateOrder($_POST);
        if ($update) {
            echo '<script>alert("Sửa Board thành công.")</script>';
            include 'view/board/board_manager.php';
        } else {
            echo '<script>alert("Sửa Board thất bại.")</script>';
            include 'view/board/board_manager.php';
        }
    }
}
?>
